import { Http, baseUrl, config } from './index';
import { App } from 'vue';
import HttpIntercepetor from './http.interceptor';

function createHttp(constructor: IHttpConstructor, baseUrl: string, config: IHttpConfig): IHttp {
	return new constructor(baseUrl, config)
}

const http: IHttp = createHttp(Http, baseUrl.value, config);


const install = (app: App): void => {
	console.log(app)
	uni.http = http;
	const httpIntercepetor = new HttpIntercepetor();
	httpIntercepetor.init();
}

export default {
	install
}